*********************************************************************************
/*   					 Plot R, C and R/C by year								*/
*********************************************************************************
clear all

local datapath "${mvpf_audits}/data/cleaned" 
local graphpath "${graphpath}" 

* GS payscale step
global step = ${step}

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}

/*------------------------------------------------------------------------------
Figure: Total revenue and costs by year
------------------------------------------------------------------------------*/
* Import data 
use "${mvpf_audits}/data/figures_rep/ap6.dta", clear
** R and C
	* set y-axis label, title, and figure name
	local ylab = "Dollars per Audit ($)"
	
	* xtitle
	global xtitle = "Year of tax return that triggered audit"

	* Preferences 
	local symbsize small
	local textsize vsmall
	
	*** Subgroup figure
	local fig_name = "connected_costs_rev_year"
	
	local lb = 0
	local ub = 20000 // round(`max', 100)
	local int = 5000 // (`ub' - `lb')/5		
	local lb_f : di %02.1f `lb'
	local ub_f : di %02.1f `ub'

	tw  (connected rev_tot primary_yr, ///
		 lcolor(sea*0.5) mcolor(sea*0.5) msymbol(C) msize(`symbsize')) ///
		(connected rev_tot_disc primary_yr, ///
		 lcolor(sea) mcolor(sea) msymbol(C) msize(`symbsize')) ///
		(connected costs_labor primary_yr, ///
		 lcolor(cranberry*0.5) mcolor(cranberry*0.5) msymbol(T) msize(`symbsize')) ///
		(connected costs_labor_future primary_yr, ///
		 lcolor(cranberry) mcolor(cranberry) msymbol(T) msize(`symbsize')) ///
		, ///
		ylabel(`lb_f'(`int')`ub_f', nogrid format(%9.0fc)) yscale(r(`lb_f' `ub_f')) ///
		ytitle("`ylab'") xtitle("${xtitle}")   ///
		legend(off) ///
		xline(2010 2014, lc(gs11) lp(dash)) ///
		${title} ${axis_size} ///
		xscale(r())  ///
		xlabel(, value labsize()  nogrid  )  
	graph export "`graphpath'/`fig_name'_ops.wmf", as(wmf) replace
	
** R/C
	* set y-axis label, title, and figure name
	local ylab = "Audit Revenue / Wage Costs"
	
	* xtitle
	global xtitle = "Year of tax return that triggered audit"

	* Preferences 
	local symbsize small
	local textsize vsmall
	
	local fig_name = "connected_rc_year"
	
	local lb = 0
	local ub = 20 // round(`max', 100)
	local int = 5 // (`ub' - `lb')/5		
	local lb_f : di %02.1f `lb'
	local ub_f : di %02.1f `ub'

	tw  (connected rc_labor2 primary_yr, ///
		 lcolor("${rc_col}*0.5") mcolor("${rc_col}*0.5") msymbol(S) msize(`symbsize')) ///
		(connected rc_labor primary_yr, ///
		 lcolor("${rc_col}") mcolor("${rc_col}") msymbol(S) msize(`symbsize')) ///
		, ///
		ylabel(`lb_f'(`int')`ub_f', nogrid format(%9.0fc)) yscale(r(`lb_f' `ub_f')) ///
		ytitle("`ylab'") xtitle("${xtitle}")   ///
		legend(off) ///
		///text(1.9 2007.5 "Total revenue/labor costs", color(plg3)) ///
		text(0.5 2012 "Baseline sample frame", size(4)) ///
		legend(off) ///
		xline(2010 2014, lc(gs11) lp(dash)) ///
		${title} ${axis_size} ///
		xscale(r())  ///
		xlabel(, value labsize()  nogrid  )  
	graph export "`graphpath'/`fig_name'_ops.wmf", as(wmf) replace
